package logic

import (
	"context"
	"week3/projectsrv/service"

	"week3/projectsrv/internal/svc"
	"week3/projectsrv/projectsrv"

	"github.com/zeromicro/go-zero/core/logx"
)

type SearchGoodsByPriceLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewSearchGoodsByPriceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SearchGoodsByPriceLogic {
	return &SearchGoodsByPriceLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// es查询商品（排序）
func (l *SearchGoodsByPriceLogic) SearchGoodsByPrice(in *projectsrv.SearchGoodsByPriceReq) (*projectsrv.SearchGoodsByPriceRes, error) {
	// todo: add your logic here and delete this line
	res, err := service.GetGoodsByPrice(int(in.SortId))
	if err != nil {
		return nil, err
	}
	return &projectsrv.SearchGoodsByPriceRes{
		Goods: res,
	}, nil
}
